package com.panshi.controller.qa;

import com.panshi.api.ITitleAip;
import com.panshi.vo.qa.DataResultQA;
import com.panshi.vo.qa.Title;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class TitleController {
    @Autowired
    ITitleAip titleAip;

    /*Title(分类)*/

    /**
     * 添加分类
     * @param title
     * @return
     */
    @PostMapping("/title/add")
    @ResponseBody
    DataResultQA addTitle(@RequestBody Title title){
        DataResultQA dataResultQA = titleAip.addTitle(title);
        return dataResultQA;
    }

    /**
     * 查询分类
     * @param title
     * @return
     */
    @PostMapping("/title/queryTitle")
    @ResponseBody
    DataResultQA<List<Title>> queryTitle(@RequestBody Title title){
        DataResultQA<List<Title>> dataResultQA = titleAip.queryTitle(title);
        return dataResultQA;
    }

    /**
     * 查询分类
     * @param title
     * @return
     */
    @PostMapping("/title/queryByNameTitle")
    @ResponseBody
    DataResultQA<Title> queryByNameTitle(@RequestBody Title title){
        DataResultQA<Title> dataResultQA = titleAip.queryByNameTitle(title);
        return dataResultQA;
    }

    /**
     * 修改分类
     * @param title
     * @return
     */
    @PostMapping("/title/updateTitle")
    @ResponseBody
    DataResultQA updateTitle(@RequestBody Title title){
        DataResultQA dataResultQA = titleAip.updateTitle(title);
        return dataResultQA;
    }

    /**
     * 禁用分类
     * @param tid
     * @return
     */
    @PostMapping("/title/forbidUseTitle/{tid}")
    @ResponseBody
    DataResultQA forbidUseTitle(@PathVariable int tid){
        DataResultQA dataResultQA = titleAip.forbidUseTitle(tid);
        return dataResultQA;
    }

    /**
     * 启用分类
     * @param tid
     * @return
     */
    @PostMapping("/title/startUseTitle/{tid}")
    @ResponseBody
    DataResultQA startUseTitle(@PathVariable int tid){
        DataResultQA dataResultQA = startUseTitle(tid);
        return dataResultQA;
    }
}
